#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

int main()
{
	printf("pid=%d ppid=%d gpid=%d sid=%d\n", getpid(), getppid(), getpgid(getpid()), getsid(getpid()));
	if (fork() == 0) {
		setsid();
		printf("pid=%d ppid=%d gpid=%d sid=%d\n", getpid(), getppid(), getpgid(getpid()), getsid(getpid()));
		sleep(3);
		printf("pid=%d ppid=%d gpid=%d sid=%d\n", getpid(), getppid(), getpgid(getpid()), getsid(getpid()));
		exit(0);
	}
	if (fork() == 0) {
		printf("pid=%d ppid=%d gpid=%d sid=%d\n", getpid(), getppid(), getpgid(getpid()), getsid(getpid()));
		sleep(3);
		printf("pid=%d ppid=%d gpid=%d sid=%d\n", getpid(), getppid(), getpgid(getpid()), getsid(getpid()));
		exit(0);
	}
	return 0;
}